package summative;

import java.awt.event.*;
import javax.swing.*;


public class MenuVectorListener implements ActionListener
{
  JMenuItem item;
  VectorList vlist;
  VectorFocusList fList;
  ViewList list;
  
  public MenuVectorListener(JMenuItem item, VectorList list, VectorFocusList fList, ViewList vlist)
  {
    this.item = item;
    this.vlist = list;
    this.fList = fList;
    this.list = vlist;
  }
  
  public void actionPerformed(ActionEvent e)
  {
	  Vector vector = (vlist.getVector((Integer.parseInt(item.getText()))-1));
	  
	  vector.toggleVisibility();
	  
	  if(vector.getVisibility() == false)
	  {
		  System.out.print(vector.getVisibility());
		  fList.removeVector(vector);
		  list.update(0);
		  
		  
	  }
	  else
	  {
		  System.out.print(vector.getVisibility());
		  fList.addVector(vector);
		  list.update(0);
		  
	  }
  }
}
